package game.leon.war.node;

import game.leon.engine.net.GateMessageHandler;
import game.leon.engine.net.GateSession;
import game.leon.engine.net.codec.GateRawMessage;
import game.leon.war.node.handler.HandlerService;
import game.leon.war.node.service.MessageDispatcher;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 在IoHandler中调用, 单一指责, 把消息给dispatcher
 * User: bianpeng
 * Date: 12-1-12
 */
@Component
public class NodeHandler implements GateMessageHandler {
    private Logger logger = Logger.getLogger(getClass());
    @Autowired
    private MessageDispatcher dispatcher;
    @Override
    public void execute(GateSession session, GateRawMessage message) {
        logger.info("recieve message: " + message.getMessage());
        dispatcher.dispatch(message);
    }
}
